package severlet;

import bean.Laterecord;
import dao.LaterecordDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet(name = "LaterecordServlet", value = "/LaterecordServlet")
public class LaterecordServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");

        //学生端：用来看本人晚归记录
        String studentname = (String) request.getSession().getAttribute("studentname");

        LaterecordDao laterecordDao=new LaterecordDao();
        //查询
        ArrayList<Laterecord> studentList = laterecordDao.getLaterecordByStudentname(studentname);
        //存入session
        request.getSession().setAttribute("studentLaterecord",studentList);

        request.getRequestDispatcher("student_laterecord.jsp").forward(request,response);
    }
}
